<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
    <h:body>	
		<ui:composition template="/admin/template.xhtml">		    			
		<p:panel header="Soutěže">	
			<h:panelGrid columns="2">
				<p:panel header="Administrace soutěží" style="min-width:500px;min-height: 1129px;">
					<h:panelGrid columns="1">	
							<p:panel header="Výběr Sezóny" style="min-width:500px;">	
							<h:form>	
								<h:panelGrid columns="2">
									<h:panelGroup>
										<h:outputText value="Sezóna : "/>
									</h:panelGroup>
									<h:panelGroup>													
										<p:selectOneMenu id="seasonSelect" value="#{searchCompetionBean.selectedSeason}" style="width: 150px">  
							                <f:selectItem itemLabel="Vyberte sezónu" itemValue="" />  
							                <f:selectItems value="#{searchCompetionBean.seasonNamesList}" />
				            			</p:selectOneMenu>			            			 
			            			</h:panelGroup>
			            			<p:commandButton value="Hledej"  actionListener="#{searchCompetionBean.fillCompetionsList}" update=":detailSouteze,:addCompetionForm"/>			            			
			            		</h:panelGrid>
			            	</h:form>		
		            		</p:panel>
		            		<p:panel>            			
	            				<h:form id="detailSouteze" >
		            				<p:dataTable id="seasonCompetionTable" var="seasonCompetion" value="#{searchCompetionBean.competions}" rowKey="#{seasonCompetion.id}"  selection="#{searchCompetionBean.selectedSeasonCompetion}" emptyMessage="Žádné soutěže nenalazeny"  selectionMode="single" tableStyle="min-width:300px;">
								        <f:facet name="header">
											<h:outputText value="Seznam souteží v sezóně "/>
											<h:outputText value="#{searchCompetionBean.selectedSeason}"/>
								        </f:facet>
								        <p:column id="modelHeader">  
								            <h:outputText value="#{seasonCompetion.name}" />  
								        </p:column>
								        <f:facet name="footer">  
							                <p:commandButton  icon="ui-icon-document" value="přidat soutěž"  update=":form:" oncomplete="competionAddDialog.show()"/>
							                <p:commandButton  icon="ui-icon-close" value="odebrat soutěž" actionListener="#{searchCompetionBean.deleteSeasonCompetion}" update=":detailSouteze,:addCompetionForm,:growl"/>         
					       				</f:facet> 
						  	        </p:dataTable>
					  	        </h:form>
					  	        <p:dialog id="dialogAddCompetion" header="Přidat soutěž do sezóny #{searchCompetionBean.selectedSeason}" widgetVar="competionAddDialog" resizable="false" width="250" showEffect="clip" hideEffect="fold" position="10,10">  
							      	 <h:form id="addCompetionForm">   
							      	    <h:panelGrid id="display" columns="2" cellpadding="4">
							      	    	   <p:selectOneMenu id="seasonSelect" value="#{searchCompetionBean.selectedCompetion}" style="width: 200px">  
							           		       <f:selectItem itemLabel="Vyberte soutěž" itemValue="" />  
							            	       <f:selectItems value="#{searchCompetionBean.competionNamesList}" />
				            				   </p:selectOneMenu>	  	 
							        	</h:panelGrid> 
							        	<p:commandButton value="Ulož změny"  actionListener="#{searchCompetionBean.saveCompetion}" update=":detailSouteze,:growl" oncomplete="competionAddDialog.hide()"/> 
							         </h:form>	
								</p:dialog>	            		    
							</p:panel>		  
					</h:panelGrid>
				</p:panel>
				<p:panel header="Editace soutěží" style="min-height: 1129px;">   
				   <h:form id="form">	
					    	<p:dataTable id="competionTable" var="competion" value="#{competionBean.competionsList}"  paginatorAlwaysVisible="false" paginatorPosition="bottom"  paginator="true" rows="15" rowKey="#{competion.id}"  selection="#{competionBean.selectedCompetion}" selectionMode="single" emptyMessage="Žádné soutěže nenalazeny" tableStyle="min-width:300px;">
						        <f:facet name="header">
									<h:outputText value="Seznam souteží" />
						        </f:facet>
						        <p:column id="modelHeader">  
						            <h:outputText value="#{competion.name}" />  
						        </p:column>
						        <f:facet name="footer">  
					            	<p:commandButton  id="editPizzaButton" icon="ui-icon-pencil" value="editace" update=":dialog" oncomplete="competionDialog.show()"/>
					                <p:commandButton  id="newPizzaButton" icon="ui-icon-document" value="nová"  update=":form" oncomplete="competionNewDialog.show()"/>
					       		</f:facet>     
					  	    </p:dataTable> 
					</h:form>
					<p:dialog id="dialog" header="Editace" widgetVar="competionDialog" resizable="false"  
					              width="300" showEffect="clip" hideEffect="fold" position="10,10">  
						      	 <h:form>   
						      	    <h:panelGrid id="display" columns="2" cellpadding="4">
						      	       <h:outputText value="Název soutěže:" />    						      
							           <h:inputText value="#{competionBean.selectedCompetion.name}" style="width:180px"/>    	 
						        	</h:panelGrid> 
						        	<p:commandButton value="Ulož změny"  actionListener="#{competionBean.updateCompetion}" update=":form,:growl" oncomplete="competionDialog.hide()"/> 
						        </h:form>	
					 </p:dialog>
				     <p:dialog id="dialogNew" header="Nová soutěž" widgetVar="competionNewDialog" resizable="false"  
					              width="300" showEffect="clip" hideEffect="fold" position="10,10">  
						      	 <h:form>   
						      	    <h:panelGrid id="display" columns="2" cellpadding="4">
						      	       <h:outputText value="Název soutěže:" />    						      
							           <h:inputText value="#{competionBean.newCompetion.name}" style="width:180px"/>    	 
						        	</h:panelGrid> 
						        	<p:commandButton value="Ulož změny"  actionListener="#{competionBean.saveCompetion}" update=":form,:dialogNew,:growl" oncomplete="competionNewDialog.hide()"/> 
						        </h:form>	
					</p:dialog>
				</p:panel>
			</h:panelGrid>
		</p:panel>			
		</ui:composition>	
	</h:body>
</html>